﻿// This software is the confidential and proprietary information of NetBay.
// Such confidential information should not be disclosed.
// NetBay copyright(c) 2012

#region

using System.Collections.Generic;
using System.ServiceModel;
using NetBay.Core.BusinessEntities.Workflow;

#endregion

namespace Rio.Workflow.Runtime
{
    [MessageContract(WrapperName = "ActionRequest", IsWrapped = true)]
    public class ActionRequest
    {
        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ActionRequest" /> class.
        /// </summary>
        public ActionRequest()
        {
            Parameters = new ParametersCollection();
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ActionRequest" /> class.
        /// </summary>
        /// <param name="wkfInstanceId">The WKF instance id.</param>
        /// <param name="wkfActionId">The WKF action id.</param>
        /// <param name="wkfDocumentStateIds">The WKF document state ids.</param>
        /// <param name="userId">The user id.</param>
        /// <param name="rguId">The rgu id.</param>
        /// <param name="uiActionType">Type of the UI action.</param>
        public ActionRequest(long wkfInstanceId, long wkfActionId, List<long> wkfDocumentStateIds, long userId,
                             long rguId, WorkflowTypeAction uiActionType)
            : this()
        {
            this.wkfInstanceId = wkfInstanceId;
            this.wkfActionId = wkfActionId;
            this.wkfDocumentStateIds = wkfDocumentStateIds;
            this.userId = userId;
            this.rguId = rguId;
            UiActionType = uiActionType;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ActionRequest"/> class.
        /// </summary>
        /// <param name="wkfInstanceId">The WKF instance id.</param>
        /// <param name="wkfActionId">The WKF action id.</param>
        /// <param name="wkfDocumentStateIds">The WKF document state ids.</param>
        /// <param name="userId">The user id.</param>
        /// <param name="rguId">The rgu id.</param>
        /// <param name="uiActionType">Type of the UI action.</param>
        /// <param name="organizationIdentifier">The organization identifier.</param>
        /// <param name="folderTypeIdentifier">The folder type identifier.</param>
        /// <param name="folderIdentifier">The folder identifier.</param>
        public ActionRequest(long wkfInstanceId, long wkfActionId, List<long> wkfDocumentStateIds, long userId,
                             long rguId, WorkflowTypeAction uiActionType, long organizationIdentifier,
                             long folderTypeIdentifier, long folderIdentifier)
            : this(wkfInstanceId, wkfActionId, wkfDocumentStateIds, userId, rguId, uiActionType)
        {
            FolderIdentifier = folderIdentifier;
            FolderTypeIdentifier = folderTypeIdentifier;
            OrganizationIdentifier = organizationIdentifier;
        }

        #endregion

        #region Instance Properties

        /// <summary>
        /// Gets or sets the user id.
        /// </summary>
        /// <value>The user id.</value>
        [MessageBodyMember(Order = 8)]
        public long FolderIdentifier { get; set; }

        /// <summary>
        /// Gets or sets the folder type identifier.
        /// </summary>
        /// <value>The folder type identifier.</value>
        [MessageBodyMember(Order = 9)]
        public long FolderTypeIdentifier { get; set; }

        /// <summary>
        /// Gets or sets the is global action.
        /// </summary>
        /// <value>The is global action.</value>
        [MessageBodyMember(Order = 6)]
        public bool IsGlobalAction { get; set; }

        /// <summary>
        /// Gets or sets the folder type identifier.
        /// </summary>
        /// <value>The folder type identifier.</value>
        [MessageBodyMember(Order = 10)]
        public long OrganizationIdentifier { get; set; }

        /// <summary>
        /// Gets or sets the parameters.
        /// </summary>
        /// <value>The parameters.</value>
        [MessageBodyMember(Order = 5)]
        public ParametersCollection Parameters { get; set; }

        /// <summary>
        /// Gets or sets the type of the UI action.
        /// </summary>
        /// <value>The type of the UI action.</value>
        [MessageBodyMember(Order = 7)]
        public WorkflowTypeAction UiActionType { get; set; }

        /// <summary>
        /// Gets or sets the rgu id.
        /// </summary>
        /// <value>The rgu id.</value>
        [MessageBodyMember(Order = 4)]
        public long rguId { get; set; }

        /// <summary>
        /// Gets or sets the user id.
        /// </summary>
        /// <value>The user id.</value>
        [MessageBodyMember(Order = 3)]
        public long userId { get; set; }

        /// <summary>
        /// Gets or sets the WKF action id.
        /// </summary>
        /// <value>The WKF action id.</value>
        [MessageBodyMember(Order = 1)]
        public long wkfActionId { get; set; }

        /// <summary>
        /// Gets or sets the WKF document state id.
        /// </summary>
        /// <value>The WKF document state id.</value>
        [MessageBodyMember(Order = 2)]
        public List<long> wkfDocumentStateIds { get; set; }

        /// <summary>
        /// Gets or sets the WKF instance id.
        /// </summary>
        /// <value>The WKF instance id.</value>
        [MessageBodyMember(Order = 0)]
        public long wkfInstanceId { get; set; }

        #endregion

        #region Instance Methods

        public override string ToString()
        {
            return
                string.Format(
                    "wkfInstanceId: {0}, wkfActionId: {1}, wkfDocumentStateIds: {2}, userId: {3}, rguId: {4}, Parameters: {5}, IsGlobalAction: {6}, UiActionType: {7}, FolderIdentifier: {8}, FolderTypeIdentifier: {9}, OrganizationIdentifier: {10}",
                    wkfInstanceId, wkfActionId, wkfDocumentStateIds, userId, rguId, Parameters, IsGlobalAction,
                    UiActionType, FolderIdentifier, FolderTypeIdentifier, OrganizationIdentifier);
        }

        #endregion
    }
}